import request from '@/utils/request'
import axios from 'axios'

const api = {
  add: '/pc/banner/add',
  list: '/pc/banner/list',
  off: '/pc/banner/off',
  on: '/pc/banner/on',
  update: '/pc/banner/update',
  upload: '/pc/anno/upload',
  getUploadForOSS: '/pc/anno/get_post_signature_for_oss_upload'
}

export default api

// 客户端上传到OSS，2024年11月3日11:32:35
export function getUploadForOSS(parameter) {
  return request({
    url: api.getUploadForOSS,
    method: 'post',
    data: parameter
  })
}


export const POST = async (url, form) => {
  try {
    return await axios({
      method: 'post',
      url,
      data: form,
      Headers: {
        'Content-Type': 'multipart/form-data'
      }
    });
  } catch (error) {
    return error;
  }
};

export function bannerAdd(parameter) {
  return request({
    url: api.add,
    method: 'post',
    data: parameter
  })
}
export function bannerList(parameter) {
  return request({
    url: api.list,
    method: 'post',
    data: parameter
  })
}
export function bannerOff(parameter) {
  return request({
    url: api.off,
    method: 'post',
    data: parameter
  })
}
export function bannerOn(parameter) {
  return request({
    url: api.on,
    method: 'post',
    data: parameter
  })
}
export function bannerUpdate(parameter) {
  return request({
    url: api.update,
    method: 'post',
    data: parameter
  })
}

export function upload(parameter) {
  return request({
    url: api.upload,
    method: 'post',
    data: parameter
  })
}

export function shopList(parameter) {
  return request({
    url: '/pc/mall/shops/listForSelect',
    method: 'post',
    data: parameter
  })
}

export function goodsList(id) {
  return request({
    url: '/pc/mall/product/listForSelect',
    method: 'post',
    data: id
  })
}